<!--
 * @Author: Allen
 * @Date: 2021-01-12 08:56:52
 * @Description: 抱怨身处黑暗，不如提灯前行。愿你在自己存在的地方，成为一束光，照亮世界的一角
 * @LastEditTime: 2021-01-13 10:00:40
 * @LastEditors: Allen
 * @FilePath: \WMS\src\views\WMS\inStorageManage\ArrivalNoteQuery\detail.vue
 * @Additional: 附加类容
-->

<template>
  <section class="carTypeConfig">
    <el-dialog
      v-dialogDrag
      title="到货单明细查询"
      :visible.sync="curPopupsVisible"
      width="1600px"
      center
      @close="sendCode"
      :close-on-click-modal="false"
      :append-to-body="true"
    >
      <dialogHeader slot="title" :title="'到货单明细查询'" :styleType="$store.state.app.dialogType"></dialogHeader>
      <one-table-template
        ref="multipleTable"
        :dynamicButtons="tableButtons"
        :dynamicComponents="tableComponents"
        :dynamicApiConfig="apiConfig"
        :dynamicTableCols="tableCols"
        :dynamicFormFields="formField"
        :dynamicIsShowSelect="false"
        :dynamicIsInitTable="true"
        :dynamicTableDefultHeight="400"
      />
    </el-dialog>
    <Remarkss
      :popupsVisible="curPopupsVisibles"
      :key="curPopupsKeys"
      :remarkJson="remarkJson"
      :isdetail="isdetail"
      @queryTab="queryTab"
    ></Remarkss>
  </section>
</template>
<script>
import { oneTableWithViewTemplateMixins } from "@/components/mixins/oneTableWithViewTemplateMixins";
import { valueObjectMixins } from "@/components/mixins/valueObjectMixins";
import { onStockApi } from "@/api/wms/onStock";
import OneTableTemplate from "@/components/wms/templates/oneTable";
import Remarkss from "./remarks";
export default {
  name: "detail",
  // 组件混入对象：{data[listQuery] methods[queryTable]}
  mixins: [oneTableWithViewTemplateMixins, valueObjectMixins],
  props: {
    detailData: {
      type: Object,
      default: {}
    }
  },
  components: {
    OneTableTemplate,
    Remarkss,
    dialogHeader: () => import("@/components/dialogHeader") //弹窗标题
  },
  created() {
    if (this.detailData.ARRIVAL_CODE) {
      this.formField.ARRIVAL_CODE = this.detailData.ARRIVAL_CODE;
      this.formField.PARTNER_SHORT_NAME = this.detailData.PARTNER_SHORT_NAME;
    }
  },
  data() {
    return {
      // 网格查询API配置对象
      isdetail: true,
      curPopupsVisibles: false,
      curPopupsKeys: false,
      remarkJson: {},
      apiConfig: onStockApi.queryarrivald, //到货单明细查询
      // 动态组件-按钮
      tableButtons: [],
      // 动态组件-查询条件
      tableComponents: [
        // 显示组件
        {
          compKey: "compKey1",
          labelName: "到货单号",
          codeField: "ARRIVAL_CODE",
          component: () => import("@/components/wms/commonInput"),
          type: "inputText",
          isMust: true,
          disabled: true
        },
        {
          compKey: "compKey2",
          labelName: "合作伙伴简称",
          codeField: "PARTNER_SHORT_NAME",
          component: () => import("@/components/wms/commonInput"),
          type: "inputText",
          isMust: true,
          disabled: true
        }
      ],
      // 动态生成网格列
      tableCols: [
        {
          prop: "controlBtn",
          label: "操作" /*操作*/,
          codeField: "controlBtn",
          width: 180,
          align: "center",
          fixed: true,
          isComponent: true,
          comps: [
            {
              compKey: "propKey2",
              align: "center",
              labelName: "明细结案" /*编辑*/,
              codeField: "editControlBtn",
              clickEvent: this.closseds,
              component: () => import("@/components/org/linkButton")
            }
          ]
        },
        {
          prop: "ARRIVAL_LINE_CODE",
          label: "行项目号",
          align: "center"
        },
        {
          prop: "PART_NO",
          label: "备件编号",
          align: "center"
        },
        {
          prop: "PART_NAME",
          label: "备件名称",
          align: "center"
        },
        {
          prop: "IS_RETROSPECT_STR",
          label: "追溯件标识",
          align: "center"
        },
        {
          prop: "RELATION_CODE",
          label: "关联单号",
          align: "center"
        },
        {
          prop: "RELATION_LINE_CODE",
          label: "关联行号",
          align: "center"
        },
        {
          prop: "ARRIVAL_QTY",
          label: "交货数量",
          align: "center"
        },
        {
          prop: "RECEIVE_QTY",
          label: "收货数量",
          align: "center"
        },
        {
          prop: "RECEIVE_NAME",
          label: "收货状态名称",
          align: "center"
        },
        {
          prop: "FINAL_USER",
          label: "结案人",
          align: "center"
        },
        {
          prop: "FINAL_TIME",
          label: "结案时间",
          align: "center"
        },
        {
          prop: "FINAL_REMARK",
          label: "结案备注",
          align: "center"
        },
        {
          prop: "REMARK",
          label: "备注",
          align: "center"
        }
      ],
      //表单查询数据（查询条件）
      formField: {
        ARRIVAL_CODE: "",
        PARTNER_SHORT_NAME: ""
      },
      handleTableRowData: {
        value: "PARTNER_CODE",
        text: "PARTNER_SHORT_NAME"
      }
    };
  },
  methods: {
    closseds(index) {
      const that = this.$refs[this.tableRef];
      if (that.list[index].RECEIVE_STATUS === "40") {
        this.$message.error("已结案的数据不能重复结案!");
      } else {
        this.curPopupsVisibles = true;
        this.curPopupsKeys = "A" + this.$utils.generateId();
        this.remarkJson = {
          ARRIVAL_D_ID: that.list[index].ARRIVAL_D_ID,
          ARRIVAL_CODE: that.list[index].ARRIVAL_CODE
        };
      }
    },
    queryTab() {
      this.queryTable();
    }
  }
};
</script>
